﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Windows.Forms;
using System.IO;

namespace ImageAcquisition
{
    class Utils
    {
        /// <summary>
        /// Show the main help document
        /// </summary>
        public static void ShowHelp()
        {
            string helpDoc = GetAppLocation();
            helpDoc += @"\Help\Help.docx";
            if (File.Exists(helpDoc))
            {
                System.Diagnostics.Process.Start(helpDoc);
            }
            else
            {
                MessageBox.Show(string.Format(Properties.Resources.HelpNotFound, helpDoc), Properties.Resources.Title);
            }
        }

        /// <summary>
        /// Go to specified position of the help document
        /// </summary>
        /// <param name="context"></param>
        public static void ShowHelp(string context)
        {
            ShowHelp();
        }

        /// <summary>
        /// Get the location/path of this application
        /// </summary>
        /// <returns></returns>
        private static string appLocation = string.Empty;
        public static string GetAppLocation()
        {
            if (appLocation.Equals(string.Empty))
            {
                Assembly ass = Assembly.GetExecutingAssembly();
                appLocation = ass.Location;
                appLocation = appLocation.Substring(0, appLocation.LastIndexOf("\\") + 1);
            }
            return appLocation;
        }
    }
}
